class Solution
{
    int ans = 0;//
    int n = 0;
public:

    void dfs(vector<int>& nums, int idx, int sum, int t)
    {
        if (idx == n)
        {
            if (sum == t)
                ans++;
        }
        else
        {
            dfs(nums, idx + 1, sum + nums[idx], t);
            dfs(nums, idx + 1, sum - nums[idx], t);
        }
    }
    int findTargetSumWays(vector<int>& nums, int t)
    {
        n = nums.size();
        dfs(nums, 0, 0, t);
        return ans;
    }
};